package hied.testing;

import hied.Example;
import hied.ExampleList;
import hied.Knowledge;
import hied.Parameters;
import hied.cleaning.Cleaner;
import hied.generator.TestSetGeneratorApplication;
import hied.generator.TrainSetGeneratorApplication;
import hied.learning.Learning;

public class SimilarityTest {

	public static void main(String[] args) {
		ExampleList trainSet = TrainSetGeneratorApplication.generateExamples(Parameters
				.getTrainSetSize());
		Knowledge knowledge = new Learning(trainSet).getKnowledge();
		Cleaner cleaner = new Cleaner(knowledge);

		for (int j = 0; j <= 10; j++) {
			Parameters.setMinSimilarity(j * 0.1f);
			int n = 20;
			float sum = 0;
			for (int i = 0; i < n; i++) {
				ExampleList testSet = TestSetGeneratorApplication.generateExamples(Parameters
						.getTestSetSize());
				// System.out.println(i);
				int all = 0;
				int success = 0;
				for (Example test : testSet.getExamples()) {
					String cleaned = cleaner.clean(test.getBefore());
					all++;
					if (!cleaned.equals(test.getAfter())) {
						// System.out.println(test.getBefore() + " ->\t" +
						// cleaned + " <>\t"
						// + test.getAfter());
					} else {
						success++;
					}
				}
				sum += (float) success / (float) all;
			}
			System.out.println(j * 0.1 + "\t" + 100 * sum / n + "%");
		}
	}
}
